﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SystemPersonInfoManage.aspx.cs" Inherits="RegisterWeb.Manager.SystemManager.SystemPersonInfoManage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet"
        type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
 

    <script type="text/javascript">
        $(function () {
            $.post('ashx/SystemPersonHandler.ashx?action=get', { action: 'get', id: 'AD20120707004' }, function (data, status) {

                $("#Administrator_Name").val(data[0].Administrator_Name);
                //$("#Administrator_Password").val(data[0].Administrator_Password);
               // $("#ReAdministrator_Password").val(data[0].Administrator_Password);
                $("#Administrator_ID").text(data[0].Administrator_ID);
            }, "JSON");
        });
        function saveInfo() {
            var Administrator_Name = $("#Administrator_Name").val();
            var Administrator_Password = $("#Administrator_Password").val();
            var OldAdministrator_Password = $("#OldAdministrator_Password").val();
            var Administrator_ID = $("#Administrator_ID").text();
            var ReAdministrator_Password=$("#ReAdministrator_Password").val();
            if (Administrator_Name != null && Administrator_Name != "" && Administrator_Password != null && Administrator_Password != "" && OldAdministrator_Password != null && OldAdministrator_Password != "" && ReAdministrator_Password != null && ReAdministrator_Password != "") {
                $.post('ashx/SystemPersonHandler.ashx?action=edit', { action: 'edit', id: Administrator_ID.toString(), Administrator_Name: Administrator_Name.toString(), Administrator_Password: Administrator_Password.toString() }, function (data, status) {
                    if (data == "ok") {

                        $.post('ashx/SystemPersonHandler.ashx?action=get', { action: 'get', id: 'AD20120707004' }, function (data, status) {

                            $("#Administrator_Name").val(data[0].Administrator_Name);
                            $("#OldAdministrator_Password").val("");
                            $("#Administrator_Password").val("");
                            $("#ReAdministrator_Password").val("");
                            $("#Administrator_ID").text(data[0].Administrator_ID);
                        }, "JSON");
                        $.messager.show({ title: '修改提示', msg: '修改成功!' });
                    }
                    else {
                        $.post('ashx/SystemPersonHandler.ashx?action=get', { action: 'get', id: 'AD20120707004' }, function (data, status) {

                            $("#Administrator_Name").val(data[0].Administrator_Name);
                            $("#OldAdministrator_Password").val("");
                            $("#Administrator_Password").val("");
                            $("#ReAdministrator_Password").val("");
                            $("#Administrator_ID").text(data[0].Administrator_ID);
                        }, "JSON");
                    $.messager.show({ title: '修改提示', msg: '修改失败!' });
                }
                });

                
            }
            else { $.messager.show({ title: '修改提示', msg: '请确保各输入框不为空!' }); }
        }
        //验证密码是否相同
        function checkPwd() {
            var ReAdministrator_Password = $("#ReAdministrator_Password").val();
            var Administrator_Password = $("#Administrator_Password").val();
            if (ReAdministrator_Password != Administrator_Password) {
                $("#error1").text("两次密码不一致");
                $("#ReAdministrator_Password").val("");
            }
            else {
                $("#error1").text("");
            }

        }
        //验证个人用户名称
        function check() {
            var value = $("#Administrator_Name").val();
            if (value != "") {
                $.post('ashx/SystemPersonHandler.ashx?action=check', { action: 'check', name: value }, function (data, status) {
                    if (data == 'ok') {
                        $("#Administrator_Name").val("");
                        $("#error").text("用户名" + value + "已存在！");
                    }
                    else {
                        $("#error").text("");
                    }
                });
            }
        }
        function reset() {

            $.post('ashx/SystemPersonHandler.ashx?action=get', { action: 'get', id: 'AD20120707004' }, function (data, status) {

                $("#Administrator_Name").val(data[0].Administrator_Name);
                $("#OldAdministrator_Password").val("");
                $("#Administrator_Password").val("");
                $("#ReAdministrator_Password").val("");
                $("#Administrator_ID").text(data[0].Administrator_ID);
            }, "JSON");

        }
        function checkOldPwd() {
            
            var value = $("#OldAdministrator_Password").val();
            if (value != "") {
                $.post('ashx/SystemPersonHandler.ashx?action=checkOldPwd', { action: 'checkOldPwd', pwd: value, id: $("#Administrator_ID").text().toString() }, function (data, status) {
                    if (data == 'ok') {
                    
                        $("#wrongPwd").text("");
                    }
                    else {
                        $("#OldAdministrator_Password").val("");
                        $("#wrongPwd").text("旧密码输入错误！");
                    }
                });

            }
           
        
        }
    </script>
</head>
<body>
    <form id="edit"  method="post">
    <div class="ftitle">个人信息维护</div>
     <div class="fitem">
        
    <label>用户名：</label>
    <input type="text" name="Administrator_Name"   validType="length[0,20]"  id="Administrator_Name" class="easyui-validatebox" required="true"  onblur="check()"/><span class="error" id="error"></span>
    </div>
  
    <div class="fitem">
    <label>旧密码：</label>
    <input type="password" name="OldAdministrator_Password" validType="length[6,32]"  id="OldAdministrator_Password" class="easyui-validatebox" required="true"  onblur="checkOldPwd()"  /><span class="error" id="wrongPwd"></span>
    </div>
    <div class="fitem">
    <label>新密码：</label>
    <input type="password" name="Administrator_Password" validType="length[6,32]"  id="Administrator_Password" class="easyui-validatebox" required="true"  />
    </div>
      <div class="fitem">
    <label>确认密码：</label>
    <input type="password" name="ReAdministrator_Password"  validType="length[6,32]"  id="ReAdministrator_Password" class="easyui-validatebox" required="true"  onblur="checkPwd()"  /><span class="error" id="error1"></span>
    </div>
    <div id="buttons">
             &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp; &nbsp;&nbsp;
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="reset()">取消</a>
  </div>

    <label id="Administrator_ID"  style="display:none" ></label>

    </form>
</body>
</html>


    
    </div>
    </form>
</body>
</html>

